<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>输出或返回一个变量的字符串表示</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.var-export" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">var_export</h1>
    <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">var_export</span> &mdash; <span class="dc-title">输出或返回一个变量的字符串表示</span></p>

   </div>
   <div class="refsect1 unknown-seealsp" id="refsect1-function.var-export-unknown-seealsp">
    <h3 class="title">描述</h3>
     <div class="methodsynopsis dc-description">
      <span class="methodname"><strong>var_export</strong></span>
       ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$expression</code></span>
      [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$return</code></span>
     ] ) : <span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span></div>

    <p class="simpara">
      此函数返回关于传递给该函数的变量的结构信息，它和
      <span class="function"><a href="var_dump.html" class="function">var_dump()</a></span> 类似，不同的是其返回的表示是合法的
      PHP 代码。
    </p>
    <p class="simpara">
     您可以通过将函数的第二个参数设置为
     <strong><code>TRUE</code></strong>，从而返回变量的表示。
    </p>
    <p class="simpara">
     比较 <span class="function"><strong>var_export()</strong></span> 和
     <span class="function"><a href="var_dump.html" class="function">var_dump()</a></span>.
    </p>
    <p class="para">
     <div class="informalexample">
      <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
&lt;pre&gt;<br /><span style="color: #0000BB">&lt;?php<br />$a&nbsp;</span><span style="color: #007700">=&nbsp;array&nbsp;(</span><span style="color: #0000BB">1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">2</span><span style="color: #007700">,&nbsp;array&nbsp;(</span><span style="color: #DD0000">"a"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"b"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"c"</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">var_export&nbsp;</span><span style="color: #007700">(</span><span style="color: #0000BB">$a</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/*&nbsp;输出：<br />array&nbsp;(<br />&nbsp;&nbsp;0&nbsp;=&gt;&nbsp;1,<br />&nbsp;&nbsp;1&nbsp;=&gt;&nbsp;2,<br />&nbsp;&nbsp;2&nbsp;=&gt;&nbsp;<br />&nbsp;&nbsp;array&nbsp;(<br />&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;=&gt;&nbsp;'a',<br />&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;=&gt;&nbsp;'b',<br />&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;=&gt;&nbsp;'c',<br />&nbsp;&nbsp;),<br />)<br />*/<br /><br /></span><span style="color: #0000BB">$b&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">3.1</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$v&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">var_export</span><span style="color: #007700">(</span><span style="color: #0000BB">$b</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">TRUE</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">$v</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">/*&nbsp;输出：<br />3.1<br />*/<br /></span><span style="color: #0000BB">?&gt;<br /></span>&lt;/pre&gt;</span>
</pre></div>
      </div>

     </div>
    </p>
   </div>

  </div></div></div></body></html>